package com.investmenttechnologyservices.rest;

import java.util.logging.Logger;

import javax.servlet.ServletException;

public class ServiceRegistry {
	private static final Logger log = Logger.getLogger(ServiceRegistry.class
			.getName());

	public static final Class<?> getServiceClass(String serviceName) throws ServletException {
		StringBuilder sb = new StringBuilder(
				"com.investmenttechnologyservices.services.");
		sb.append(Character.toUpperCase(serviceName.charAt(0))); // "First capitalized"
																	// - class
																	// name
		sb.append(serviceName.substring(1));
		sb.append("Service");
		String className = sb.toString();

		try {
			Class<?> aclass = Class.forName(className);
			return aclass;

		} catch (Exception e) {
			String msg = "fail to find service " + serviceName + " - "
					+ e.getLocalizedMessage();
			log.severe(msg);
			throw new ServletException(msg);
		}
	}

}
